package com.qkl.upload.publics.dto;

import lombok.Data;

@Data
public class BusinessDTO<T> {

    private boolean sucess;

    private String message;

    private Integer code;

    private T businessObject;

    public static BusinessDTO failBusiness(String message) {
        return failBusiness(null,message);
    }

    public static BusinessDTO failBusiness(Integer code,String message) {
        BusinessDTO fail = new BusinessDTO();
        fail.setSucess(false);
        fail.setCode(code);
        fail.setMessage(message);
        return fail;
    }

    public static <T> BusinessDTO<T> sucessBusiness(Object businessObject) {
        return sucessBusiness(businessObject, null);
    }

    public static <T> BusinessDTO<T> sucessBusiness(Object businessObject, String message) {
        BusinessDTO<T> sucess = new BusinessDTO<>();
        sucess.setSucess(true);
        sucess.setMessage(message);
        sucess.setBusinessObject((T) businessObject);
        return sucess;
    }
}
